package com.cipta.lomob.fragments;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.ProgressBar;

import com.cipta.lomob.R;
import com.cipta.lomob.adapter.NotificationAdapter;
import com.cipta.lomob.base.BaseFragment;

public class NotificationFragment extends BaseFragment{
	private ListView lvNotification;
	private ProgressBar indicator;
	public static String FRAGMENT_TAG = "NotificationFragment";
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.fragment_notification, container, false);
		initializeViews(view);
		return view;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		
		initializeProcess();
		initializeActions();
	}
	
	@Override
	public void initializeViews(View view) {
		// TODO Auto-generated method stub
		super.initializeViews(view);
		setHasOptionsMenu(true);
		getActivity().getActionBar().setTitle("Notification");
		getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
		lvNotification = (ListView)view.findViewById(R.id.lvNotification);
		indicator = (ProgressBar)view.findViewById(R.id.pb_indicator);
		indicator.setVisibility(View.GONE);
	}
	
	@Override
	public void initializeProcess() {
		// TODO Auto-generated method stub
		super.initializeProcess();
		
		NotificationAdapter notificationAdapter = new NotificationAdapter(getActivity());
		lvNotification.setAdapter(notificationAdapter);
	}
	
	@Override
	public void initializeActions() {
		// TODO Auto-generated method stub
		super.initializeActions();
		
		lvNotification.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		
		if (item.getItemId()==android.R.id.home) {
			getActivity().finish();
		}
		
		return super.onOptionsItemSelected(item);
	
	}
}
